package com.example.basicdemo.model.builder;

import com.isyscore.os.dev.api.IsyscoreRequestBuilder;
import com.isyscore.os.dev.util.IsyscoreHashMap;
import com.isyscore.os.dev.util.RequestUtils;
import com.isyscore.os.dev.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

public class QueryRoleAclByIdRequestBuilder extends IsyscoreRequestBuilder {
    private IsyscoreHashMap headers;

    /**
     * 角色Id
     */
    private String roleId;

    /**
     * 应用编码
     */
    private String appCode;

    public String getRoleId() {
        return roleId;
    }

    public QueryRoleAclByIdRequestBuilder setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
    }

    public String getAppCode() {
        return appCode;
    }

    public QueryRoleAclByIdRequestBuilder setAppCode(String appCode) {
        this.appCode = appCode;
        return this;
    }

    public IsyscoreHashMap getHeaders() {
        return headers;
    }

    public QueryRoleAclByIdRequestBuilder setHeaders(IsyscoreHashMap headers) {
        this.headers = headers;
        return this;
    }

    @Override
    public boolean validate() {
        if (StringUtils.isEmpty(roleId)) {
            throw new NullPointerException("roleId should not be NULL or EMPTY!");
        }
        if (StringUtils.isEmpty(appCode)) {
            throw new NullPointerException("appCode should not be NULL or EMPTY!");
        }
        return true;
    }

    @Override
    public IsyscoreRequestBuilder setRequestHeader(HttpServletRequest request) {
        this.headers = RequestUtils.getRequestHeader(request);
        return this;
    }
}
